def fun(*args):
    print(args, "tpe=", type(args))


fun(1, 2, 3, 4, 5)


def chain_generator_old(*args_iterable):
    for arg in args_iterable:
        for item in arg:
            yield item


def chain_generator_new(*args_generator_tuple):
    """通过yield from 可简化生成器的生成"""
    for gen_item in args_generator_tuple:
        yield from gen_item


gen1 = (x for x in range(1, 4))  # 1,2,3生成器
gen2 = (x for x in range(4, 7))  # 4,5,6
gen3 = (x for x in range(7, 10))  # 7,8,9

gen4 = (x for x in range(10) if x % 2 == 0)

# print(list(gen1), list(gen2), list(gen3)) [1, 2, 3][4, 5, 6][7, 8, 9]

# chained_generator = chain_generator_old(gen1, gen2, gen3)

# for item in chained_generator:
#     print(item)


chained_generator = chain_generator_new(gen1, gen2, gen3, gen4)

for num in chained_generator:
    print("num===", num)
